<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
        <style>
            * {
                margin: 0;
                padding: 0;
                box-sizing: border-box;
            }
            .canvas {
                display: block;
                margin: 25px auto;
                border: 1px solid #aaa;
            }
        </style>
        <script>
            window.addEventListener("load", function () {
                const c = document.querySelector(".canvas");
                c.width = 650;
                c.height = 650;
                const ctx = c.getContext("2d");
                ctx.moveTo(50, 50);
                ctx.lineTo(50, 350);
                ctx.lineTo(350, 350);
                ctx.lineTo(350, 50);
                ctx.closePath(); // ctx.lineTo(50, 50);
                ctx.stroke();
            });
        </script>
    </head>
    <body>
        <canvas class="canvas">你的浏览器不支持Canvas，请升级版本或更换浏览器！</canvas>
    </body>
</html>
